#ifndef PST_SELECTDATADIALOG_H
#define PST_SELECTDATADIALOG_H

#include <ElaWidget.h>
#include <QModelIndexList>
#include <QPair>
#include <QList>

class ElaComboBox;
namespace pst
{
    class Curve2DKeySelcetBar;

    class SelectDatatDialog : public ElaWidget
    {
        Q_OBJECT

    public:
        SelectDatatDialog(QWidget* parent = nullptr);

        void setDialogTitle(const QString& title);
        QString getDialogTitle() const;

        /// @brief 设置所有key数据
        void setKeyDataList(const QList<QPair<QString, QVector<double>>>& dataList);
        QList<QPair<QString, QVector<double>>> getkeyDataList() const;

        void setValueDataList(const QList<QPair<QString, QVector<double>>>& dataList);
        QList<QPair<QString, QVector<double>>> getValueDataList() const;

        void updateUI();

        void SetOptionalKey(const QList<QString>& optionalKeyList) {
            m_optionalKeyList = optionalKeyList;
        }

    public slots:
        void slot_sendChosenInfo();
        void slot_variableIndexChanged(int index);
    signals:
        /// @brief 发送选择的数据信息
        /// variableIndex 选择的变量下标
        /// chosenData 除variableIndex外，选择的每一个变量和对应的数据
        /// valueIndexs 选择的value的下标
        void signal_sendSelectedInfo(int& variableIndex,
            QList<QPair<int, QList<int>>>& chosenData, QList<int>& valueIndexs);

        //public slots:
        //    void slot_getSelectedInfo(const QModelIndexList& ids);

    private:
        QList<QPair<QString, QVector<double>>> m_keyDataList;
        QList<QPair<QString, QVector<double>>> m_valueDataList;
        ElaComboBox* m_variableAxisValue; //扫描参数
        QList<Curve2DKeySelcetBar*> m_keySelectBarList;//所有key列
        Curve2DKeySelcetBar* m_valueSelectBar; //value列
        QList<QString> m_optionalKeyList;
        QList<int> m_indexMapping;
    };
}

#endif